/* GSApplyApproveSaveAction.java
 *
 * Project/Product: GWBS2009
 *
 * Modify Information:
 * =============================================================================
 *   Author	Date       Description
 *   ----------	---------- ---------------------------------------------------
 *   np	2009-3-30	First release
 *
 * Licensed Materials - Property of APEP
 * =============================================================================
 *    (C) COPYRIGHT Shanghai Auto Mart E-Procurement Co., Ltd. 2007 - 2009
 *    All Rights Reserved.
 *
 *    This software is the confidential and proprietary information of
 *    Shanghai Auto Mart E-Procurement Co., Ltd. ("Confidential Information").
 *    You shall not disclose such Confidential Information and shall use it only
 *    in accordance with the terms of the license agreement you entered into 
 *    with Shanghai Auto Mart E-Procurement Co., Ltd.
 *
 * Noties:
 * =============================================================================
 * 
 */

package com.hitrust.gs.action;

import java.util.ArrayList;

import system.LoginContext;

import com.hitrust.gs.bean.GSOrderApplyBean;
import com.hitrust.gs.business.GSOrderApplyProcessor;
import com.hitrust.gs.form.GSApplyForm;
import com.hitrust.gs.lib.GSBaseConstants;
import com.hitrust.gs.service.GSBaseAction;
import com.hitrust.gs.service.GSBaseForm;

public class GSApplyApproveSaveAction extends GSBaseAction {

    /* (non-Javadoc)
     * @see com.hitrust.gs.service.GSBaseAction#execute(com.hitrust.gs.service.GSBaseForm)
     */
    public String execute(GSBaseForm aForm) throws Exception {
        LoginContext context = (LoginContext) aForm.getSession().getAttribute(
                GSBaseConstants.LOGIN);
        GSApplyForm applyForm=(GSApplyForm) aForm;
        String[] ids=applyForm.getApplyids();
        String[] sendcount=applyForm.getSendcount();
        String[] senddate=applyForm.getSenddate();
        String[] sendtime=applyForm.getSendtime();
        GSOrderApplyProcessor apro=new GSOrderApplyProcessor();
        ArrayList tList=new ArrayList();
        for (int i = 0; i < ids.length; i++) {
            String id=ids[i].split("@")[0];
            GSOrderApplyBean apply=apro.getOrderApplyBeanById(id);
            apply.setSend_count(Double.parseDouble(sendcount[i]));
            apply.setSend_date(senddate[i]);
            apply.setSend_time(sendtime[i]);
            tList.add(apply);
        }
        String msg="";
        try {
            msg=apro.insertApply(context, tList);
            aForm.getRequest().setAttribute("message", msg);
        } catch (Exception e) {
            aForm.getRequest().setAttribute("action", "A151101.do");
            throw  e;
        }
        return GSBaseConstants.FORWARD_SUCCESS;
    }

}
